/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.edu.amu.wmi.kino.visualjavafx.visualjavafxgui.editor.visual.widgets;

import java.awt.BasicStroke;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import org.netbeans.api.visual.widget.Scene;
import pl.edu.amu.wmi.kino.visualjavafx.model.objects.shapes.Elipse;

/**
 *
 * @author psychollek
 */
public class ElipseWidget extends ShapeWidget{

    private Elipse elipse;
    public ElipseWidget (Scene scene, Elipse elipse) {
        super (scene,elipse);
        this.elipse = elipse;
    }

    @Override
    public Rectangle calculateClientArea(){
        Rectangle r = super.calculateClientArea();

        r.setRect(-(elipse.getBorderWidth()+elipse.getSizeH())/2,
                  -(elipse.getBorderWidth()+elipse.getSizeV())/2,
                  elipse.getSizeH()+elipse.getBorderWidth(),
                  elipse.getSizeV()+elipse.getBorderWidth());

        return r;
    }

    @Override
    protected void paintWidget () {
        Graphics2D g = getGraphics ();
        int width = (new Double(elipse.getSizeH())).intValue();
        int heigh = (new Double(elipse.getSizeV())).intValue();
        g.setColor (elipse.getFillColor());
        int xDelta = (new Double(-(elipse.getSizeH())/2)).intValue();
        int yDelta = (new Double(-(elipse.getSizeV())/2)).intValue();
        g.fillOval(xDelta, yDelta, width , heigh );
        g.setColor(elipse.getBorderColor());
        BasicStroke stroke = new BasicStroke(new Float(elipse.getBorderWidth()), BasicStroke.CAP_ROUND , BasicStroke.JOIN_ROUND);
        g.setStroke(stroke);
        g.drawOval(xDelta, yDelta, width , heigh );
    }


}
